<template>
  <div class="calendar-container">
    <div class="con-list">
            <!-- 日历 -->
            <el-calendar>
                <!-- 插槽 -->
                <template slot="dateCell" slot-scope="{date, data}">
                    <!--  date   单元格代表的日期  data { type, isSelected, day}，type 表示该日期的所属月份，可选值有 prev-month，current-month，next-month；isSelected 标明该日期是否被选中；day 是格式化的日期，格式为 yyyy-MM-dd-->
                    <div>
                        <!-- 这里加了周六周天的判断 -->
                        <div :class="(date.getDay()==6 || date.getDay()==0)?'weeked' :'notweeked'">{{ data.day.split('-').slice(2).join('-') }} {{ data.isSelected ? '✔️' : ''}}</div>
                        <!-- 数组循环 -->
                        <div class="cell" v-for="(item,index) in tableData" :key="index">
                            <!-- 加数据 -->
                            <div v-if="data.day == item.day">
                                <div v-for="(it,index) in tableData[index].info" :key="index">
                                    <div class="info">
                                        <i class="el-icon-info"></i>
                                        <b>【{{it.name}}】 </b>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </template>
            </el-calendar>
        </div>
  </div>
</template>

<script>
export default {
  name: 'Calendar',
  value: new Date(),
  data() {
            return {
                tableData: [
                    {
                        day:'2022-11-01',
                        info:[
                            {
                                all:' all1',
                                name: 'name1',
                            },
                            {
                                all:'all2',
                                name: 'name1',
                            },
                        ],
                    },
                     
                ],
            }
        },
}
</script>
<style lang="less" scoped>
    ::v-deep .el-calendar{
        background-color: var(--bgColor);
    }
    ::v-deep .el-calendar__header{
        border-bottom: 1px solid var(--borderColor);
    }

    .notweeked{
        padding: 5px;
        text-align: center;
        // color: #354158;
        background-color: var(--bgColor);
    }
    .weeked{
        padding: 5px;
        text-align: center;
        background-color: rgba(255,0,0,.1);
        background-image: url(@/assets/imgs/rest.png);
        background-size: 30px;
        background-repeat: no-repeat;
        background-position: right;
        background-position-y: -4px;
    }
    ::v-deep .el-calendar-table .el-calendar-day{
      height: 34px;
      padding: 0%;
    }
</style>

